#include <vcl.h>
#pragma hdrstop


#include <System.hpp>


int c = 0, i = 0, n = 0, m = 0, mi = 0, mc = 0;
Char ms = '\0';
String rs;
bool equals = false;
int a[ 1000000/*# range 1..1000000*/ ], B[ 1000000/*# range 1..1000000*/ ];


String __fastcall i2s( int i )
{
  String result;
  Str( i, result );
  return result;
}

int main(int argc, char* argv[])
{
  Read( n ); ReadLn( m );
  FillChar( a, 0, m );
  ms = '+';
  equals = false;
  rs = "";
  Read( c );
  a[c - 1]++;
  mi = c;
  mc = 1;
  B[1 - 1] = c;
  for ( int stop = n, i = 2; i <= stop; i++)
  {
    Read( c );
    a[c - 1]++;
    equals = a[c - 1] == mc;
    if ( equals )
      B[i - 1] = - 1;
    else
    {
      if ( a[c - 1] > mc )
      {
        mi = c;
        mc = a[c - 1];
      }
      B[i - 1] = mi;
    }
  }
  Write( B[1 - 1] );
  for ( int stop = n, i = 2; i <= stop; i++)
    if ( B[i - 1] == - 1 )
      Write( " +" );
    else
    {
      Write( ' ' ); Write( B[i - 1] );
    }
  writeln;
  return 0;
}
